package com.demo2.todo.repository;

import com.demo2.todo.model.entity.User;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.Optional;

/**
 * @author evi
 */
public interface UserRepository extends JpaRepository<User, Long> {
    Optional<User> findByUsername(String username);
    Boolean existsByUsername(String username);
    @Query("SELECT u.username FROM User u WHERE u.id = :id")  // 只查询 username 字段
    String findUsernameById(Long id);
}